﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;
using System.Web;

namespace CMS.PBDesk.Framework.Web
{
    public static class CookieHelper
    {
        #region CookieName Constants
        public const string COOKIE_USER = "UserInfo";
        public const string COOKIE_USER_NAME = "UserName";
        public const string COOKIE_AUTH = "AuthInfo";
        public const string COOKIE_AUTH_PROVIDER_NAME = "AuthProivder";
        public const string COOKIE_AUTH_PROVIDER_UID = "AuthProivderUid";
        public const string COOKIE_AUTH_LOGIN_PROVIDER_NAME = "LoginProivder";
        public const string COOKIE_AUTH_LOGIN_PROVIDER_UID = "LoginProivderUiD";
        public const string COOKIE_GIGYA_INFO = "gigyaInfo";
        #endregion

        public static void WriteAuthCookies(string authProivder, string authProivderUid, string loginProivder, string loginProviderUid)
        {
            CookieManager.WriteCookie(COOKIE_AUTH, new NameValueCollection 
                                                            {
                                                                {COOKIE_AUTH_PROVIDER_UID, authProivderUid},
                                                                {COOKIE_AUTH_PROVIDER_NAME, authProivder},
                                                                {COOKIE_AUTH_LOGIN_PROVIDER_NAME, loginProivder},
                                                                {COOKIE_AUTH_PROVIDER_UID, loginProviderUid}
                                                            });
        }

        public static void ReadAuthCookies(out string authProivder, out string authProivderUid, out string loginProvider, out string loginProviderUid)
        {
            authProivderUid = CookieManager.GetCookieValue(COOKIE_AUTH, COOKIE_AUTH_PROVIDER_UID);
            authProivder = CookieManager.GetCookieValue(COOKIE_AUTH, COOKIE_AUTH_PROVIDER_NAME);
            loginProvider = CookieManager.GetCookieValue(COOKIE_AUTH, COOKIE_AUTH_LOGIN_PROVIDER_NAME);
            loginProviderUid = CookieManager.GetCookieValue(COOKIE_AUTH, COOKIE_AUTH_LOGIN_PROVIDER_UID);
        }

        public static bool WriteUserInfoCookies(string userName)
        {
            return false;
        }

        public static void ReadUserInfoCookies(out string userName)
        {
            userName = string.Empty;           
        }


    }
}
